# -*- coding: utf-8 -*-
$:.push('gen-rb')

require 'thrift'
require 'user_constants'
require 'user_storage'

class UserHandler
  def set_user(user)
    puts 'Set user: ' + user.inspect
  end

  def get_user(id)
    return Model::User.new(:id => id, :name => "Name: #{id}")
  end
end

processor = Model::UserStorage::Processor.new(UserHandler.new())
transport = Thrift::ServerSocket.new(9090)
transportFactory = Thrift::BufferedTransportFactory.new()
server = Thrift::SimpleServer.new(processor, transport, transportFactory)

puts "Starting the server..."
server.serve()
puts "Stoped the server..."
